package grex.Nodes;

import grex.Data.PredictionContainer;

public class Times extends Node implements IContinuousOperator{
  private static final int NROFCILDREN = 2;
 
  public Times() {
    super(NROFCILDREN);
  }

  public synchronized void execute(Node parent,PredictionContainer data,int mode) throws GeneException {
      this.parent = parent;
    
    Node[] childs = this.getChildren();
    PredictionContainer lResult = data;
    PredictionContainer rResult = data.clone();
    childs[0].execute(this, lResult, mode);
    childs[1].execute(this, rResult, mode);
        for (double[] key : data.keySet()) {            
                data.get(key).setPrediction(lResult.get(key).getPrediction() * rResult.get(key).getPrediction());
        }
        
  }
  
  public Object clone() {
    Times newGreater = new Times();
    newGreater.setOptions(ops);
    cloneChildren(newGreater);
    newGreater.setParent(parent);
     return newGreater;
  }
  public String toString() {
    return "*";
  }

}
